package com.ctgu.examonline.service.serviceImpl;

import com.ctgu.examonline.dao.AnswerDao;
import com.ctgu.examonline.entity.Answer;
import com.ctgu.examonline.service.AnswerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by 段敏杰 at 2020-08-06 21:36
 */
@Service
public class AnswerServiceImpl implements AnswerService {
    @Resource
    private AnswerDao answerDao;

    //查询所有答案
    @Override
    public List<Answer> listAnswer() {
        return answerDao.selectAllAnswer();
    }

    //增加一个答案
    @Override
    public void saveOneAnswer(String ans_detail, Integer pro_no) {
        answerDao.insertOneAnswerByDetailAndProNo(ans_detail, pro_no);
    }

    //删除一个答案
    @Override
    public void removeOneAnswer(Integer ans_no) {
        answerDao.deleteOneAnswerByNo(ans_no);
    }

    //修改一个答案
    @Override
    public void updateOneAnswer(String new_ans_detail, Integer ans_no) {
        answerDao.updateOneAnswerByDetail(new_ans_detail, ans_no);
    }

    //查询一个答案
    @Override
    public Answer getOneAnswer(Integer ans_no) {
        return answerDao.selectOneAnswerByNo(ans_no);
    }
}
